{{define "chapter02/user_add3.html"}}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="/static/js/jquery.min.js"></script>
</head>
<body>
    用户添加页面<br>

    <form>
        用户名：<input type="text" id="username"><br>
        密&nbsp;&nbsp;&nbsp;码：<input type="password" id="password"><br>
        年&nbsp;&nbsp;&nbsp;龄：<input type="text" id="age"><br>
        <input type="submit" value="提交" id="add_btn">
    </form>

    <script>
        var add_btn = document.getElementById('add_btn')
        add_btn.onclick = function() {
            var username = document.getElementById("username").value;
            var password = document.getElementById("password").value;
            var age = document.getElementById("age").value;

            // 发生ajax请求
            $.ajax({
                url:"/do_user_add3",
                type: "POST",
                data: {
                    "username":username,
                    "password":password,
                    "age":age
                },
                // 成功后回调函数，data为后端返回的数据
                success:function(data){
                    alert(data["code"]);
                    alert(data["msg"])
                },
                fail:function(data){

                }
            })
        }
    </script>
</body>
</html>
{{end}}